﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace XDCCManager.Popups
{
	/// <summary>
	/// Interaction logic for ConnectionProgress.xaml
	/// </summary>
	public partial class ConnectionProgress : UserControl, Controls.IAnimationStartStop
	{
		public ConnectionProgress()
		{
			this.InitializeComponent();
		}

		public string Message
		{
			get { return (string)GetValue(MessageProperty); }
			set { SetValue(MessageProperty, value); }
		}

		// Using a DependencyProperty as the backing store for Message.  This enables animation, styling, binding, etc...
		/// <summary>
		/// Progress message.
		/// </summary>
		public static readonly DependencyProperty MessageProperty =
			DependencyProperty.Register("Message", typeof(string), typeof(ConnectionProgress), new UIPropertyMetadata(string.Empty));

		public bool Canceled
		{
			get { return (bool)GetValue(CanceledProperty); }
			set { SetValue(CanceledProperty, value); }
		}

		// Using a DependencyProperty as the backing store for Canceled.  This enables animation, styling, binding, etc...
		/// <summary>
		/// Indicates if the Cancel button was clicked.
		/// </summary>
		public static readonly DependencyProperty CanceledProperty =
			DependencyProperty.Register("Canceled", typeof(bool), typeof(ConnectionProgress), new UIPropertyMetadata(false));

		private void cancel_Click(object sender, RoutedEventArgs e)
		{
			Canceled = true;
			if (CancelRequested != null)
				CancelRequested(this, new EventArgs());
		}

		public event EventHandler CancelRequested;

		public void ResetState()
		{
			Canceled = false;
		}

		#region IAnimationStartStop Members

		public void Begin()
		{
			loading.Begin();
		}

		public void End()
		{
			loading.End();
		}

		#endregion
	}
}